﻿using System;

namespace NodeJS.stream
{
    /// <summary>
    /// Duplex streams are streams that implement both the Readable and Writable interfaces.
    /// </summary>
    public class Duplex : EventEmitter, IReadable, IWritable
    {
        /// <summary>
        /// In classes that extend the Duplex class, make sure to call the constructor so that the buffering settings can be properly initialized.
        /// </summary>
        /// <param name="options">options Object Passed to both Writable and Readable constructors. Also has the following fields:
        /// <para>allowHalfOpen Boolean Default=true. If set to false, then the stream will automatically end the readable side when the writable side ends and vice versa.</para>
        /// </param>
        public Duplex(object options = null)
        {
        }
        

        public virtual StringOrBuffer Read(int size = 0)
        {
            return null;
        }

        public virtual void SetEncoding(Encoding encoding)
        {
        }

        public virtual void Resume()
        {
        }

        public virtual void Pause()
        {
        }

        public virtual IWritable Pipe(IWritable destination, object options = null)
        {
            return null;
        }

        public virtual void Unpipe(IWritable destination = null)
        {            
        }

        public virtual void Unshift(StringOrBuffer chunk)
        {            
        }

        public virtual bool Write(StringOrBuffer chunk, string encoding = "", Action callback = null)
        {
            return false;
        }

        public virtual bool End(StringOrBuffer chunk = null, string encoding = "", Action callback = null)
        {
            return false;
        }
    }
}
